{extend name="layout/iframe" /}

{block name="content"}
<div class="layui-card-body layui-layout-admin" style="padding: 15px;">
    <form class="layui-form" action="" lay-filter="component-form-group">
        <div class="layui-form-item layui-form-text">
            <label class="layui-form-label"><span class="required">*</span>是否启用</label>
            <div class="layui-input-block">
                <input type="checkbox" name="status" {if condition="($info.status == 1)"}checked=""{/if} lay-skin="switch" lay-text="启用|禁用"><div class="layui-unselect layui-form-switch" lay-skin="_switch"><em>启用</em><i></i></div>
            </div>
        </div>
        <div class="layui-form-item layui-form-text">
            <label class="layui-form-label"><span class="required">*</span>充值模板名称</label>
            <div class="layui-input-block">
                <input type="text" class="layui-input" name="name" value="{$info.name}" maxlength="40" lay-verify="name" placeholder="" autocomplete="off">
            </div>
        </div>
        <div class="recharge-rule-group">
            {foreach name="info.rule_json" item="rule" key="rulekey"}
                <div class="layui-form-item layui-form-text rule-group">
                    <div class="layui-inline">
                        <label class="layui-form-label"><span class="required">*</span>充值金额</label>
                        <div class="layui-input-inline">
                            <input type="text" class="layui-input recharge_money" name="recharge_money[{$rulekey}]" value="{$rule.recharge_money / 100}" maxlength="10" placeholder="元" autocomplete="off">
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label" style="width: 70px;"><span class="required">*</span>赠送金额</label>
                        <div class="layui-input-inline">
                            <input type="text" class="layui-input gift_money" name="gift_money[{$rulekey}]" value="{$rule.gift_money / 100}" maxlength="10" placeholder="元" autocomplete="off">
                        </div>
                    </div>
                    {if condition="($rulekey > 0)"}
                        <div class="layui-inline">
                            <div class="layui-input-inline">
                                <button type="button" class="layui-btn layui-btn-danger delRule-btn"><i class="layui-icon layui-icon-delete"></i></button>
                            </div>
                        </div>
                    {/if}
                </div>
            {/foreach}
        </div>

        <div class="layui-form-item layui-form-text">
            <div class="layui-inline">
                <label class="layui-form-label"></label>
                <div class="layui-input-inline">
                    <button type="button" class="layui-btn layui-btn-normal addRule-btn"><i class="layui-icon"></i>新增充值规则</button>
                </div>
            </div>
        </div>

        <input type="hidden" name="id" value="{$info.id}">

        <div class="layui-form-item layui-row layui-col-xs12">
            <div class="layui-input-block">
                <div class="layui-footer">
                    <button type="button" class="layui-btn layui-btn-primary close-btn">取消</button>
                    <button type="button" class="layui-btn" lay-submit="" lay-filter="laySave">保存 <i class="layui-icon">&#xe609;</i></button>
                </div>
            </div>
        </div>
    </form>
</div>

<input type="hidden" class="save_url" value="{:url('admin/'.strtolower($model).'/savepost')}">
{/block}

{block name="pagescript"}
<script src="__STATIC__/admin/pages/js/rechargerule.js" type="text/javascript"></script>
{/block}